package cn.kais.drawer.menu;

import com.google.zxing.BarcodeFormat;

import java.util.Objects;

/**
 * 码类型
 * 'CODE128'
 * 'CODE128B'
 * 'CODE39'
 * 'CODABAR'
 * <p>
 * 'CODE11'
 * 'CODE16K'
 * 'CODE32'
 * 'CODABLOCKF'
 */
public enum MenuCodeBarFormat {

    // 方
//    AZTEC("AZTEC", BarcodeFormat.AZTEC),
    QR_CODE("QR_CODE", BarcodeFormat.QR_CODE),
    DATA_MATRIX("DATA_MATRIX", BarcodeFormat.DATA_MATRIX),

    // 条
    CODABAR("CODABAR", BarcodeFormat.CODABAR),
    CODE_39("CODE_39", BarcodeFormat.CODE_39),
    CODE_93("CODE_93", BarcodeFormat.CODE_93),
    CODE_128("CODE_128", BarcodeFormat.CODE_128),
    EAN_8("EAN_8", BarcodeFormat.EAN_8),
    EAN_13("EAN_13", BarcodeFormat.EAN_13),

    ;

    public final String code;
    public final BarcodeFormat format;

    MenuCodeBarFormat(String code, BarcodeFormat format) {
        this.code = code;
        this.format = format;
    }

    public static MenuCodeBarFormat onParseCode(String code) {
        for (MenuCodeBarFormat menu : MenuCodeBarFormat.values()) {
            if (Objects.equals(menu.code, String.valueOf(code))) {
                return menu;
            }
        }
        return CODE_128;
    }

}
